//
//  ZYCTourRecordMenuView.m
//  ZDSC
//
//  Created by ZDTX on 2021/8/5.
//

#import "ZYCTourRecordMenuView.h"

@interface ZYCTourRecordMenuView ()


@property (nonatomic, strong) UIView *line;
@end
@implementation ZYCTourRecordMenuView

- (void)setLeftStr:(NSString *)leftStr{
    _leftStr = leftStr;
    [_leftButton setTitle:leftStr forState:UIControlStateNormal];
}
- (void)setRightStr:(NSString *)rightStr{
    _rightStr = rightStr;
    [_rightButton setTitle:rightStr forState:UIControlStateNormal];
}
- (instancetype)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        
        [self addSubview:self.leftButton];
        [self addSubview:self.rightButton];
        [self addSubview:self.line];
        
        [self.leftButton mas_makeConstraints:^(MASConstraintMaker *make) {
            make.bottom.equalTo(self);
            make.size.mas_equalTo(CGSizeMake(self.bounds.size.width / 2, 46));
            make.left.equalTo(self);
        }];
        
        [self.rightButton mas_makeConstraints:^(MASConstraintMaker *make) {
            make.bottom.equalTo(self);
            make.size.mas_equalTo(CGSizeMake(self.bounds.size.width / 2, 46));
            make.right.equalTo(self);
        }];
        
        [self.line mas_makeConstraints:^(MASConstraintMaker *make) {
            make.centerX.equalTo(self);
            make.top.equalTo(self).offset(12.0f);
            make.bottom.equalTo(self).offset(-12.0f);
            make.width.mas_equalTo(1);
        }];
        

    }
    return self;
}


//- (MenuButton *)setMenuButtonWith:(NSString *)title {
//    // 获取按钮
//    MenuButton *menuButton = [MenuButton buttonWithType:UIButtonTypeCustom];
//    [menuButton setTitleColor:_normalColor forState:UIControlStateNormal];
////    [menuButton setTitleColor:_selectColor forState:UIControlStateSelected];
//    UIImage *normalImage = [[UIImage imageNamed:@"arrow_down"] imageWithRenderingMode:UIImageRenderingModeAlwaysTemplate];
//    [menuButton setImage:normalImage forState:UIControlStateNormal];
//    [menuButton setTitle:title forState:UIControlStateNormal];
//    menuButton.titleLabel.font = _titleFont;
//    menuButton.selected = NO;
//    [menuButton addTarget:self action:@selector(btnClick:) forControlEvents:UIControlEventTouchUpInside];
//    return menuButton;
//}


- (MenuButton *)leftButton {
    if (!_leftButton) {
        _leftButton = [MenuButton buttonWithType:UIButtonTypeCustom];
        _leftButton.titleLabel.font = kCustomFont(@"PingFangSC-Regular", 15.0f);;
        [_leftButton setTitleColor:HEX_RGB(@"#2B302D") forState:UIControlStateNormal];

        _leftButton.tag = 1000;
        [_leftButton setImage:[UIImage imageNamed:@"arrow_down"] forState:UIControlStateNormal];
        [_leftButton addTarget:self action:@selector(clickBtnAction:) forControlEvents:UIControlEventTouchUpInside];

    }
    return _leftButton;
}


- (MenuButton *)rightButton {
    if (!_rightButton) {
        _rightButton =  [MenuButton buttonWithType:UIButtonTypeCustom];
        _rightButton.titleLabel.font = kCustomFont(@"PingFangSC-Regular", 15.0f);;
        [_rightButton setTitleColor:HEX_RGB(@"#2B302D") forState:UIControlStateNormal];
        [_rightButton setImage:[UIImage imageNamed:@"arrow_down"] forState:UIControlStateNormal];
        [_rightButton addTarget:self action:@selector(clickBtnAction:) forControlEvents:UIControlEventTouchUpInside];
        _rightButton.tag = 1001;

    }
    return _rightButton;
}


- (UIView *)line {
    if (!_line) {
        _line = [[UIView alloc] init];
        _line.backgroundColor = HEX_RGB(@"#EFEFEF");
    }
    return _line;
}



- (void)clickBtnAction:(UIButton *)sender{

    if (sender.tag == 1000) {
        if ([self.delegate respondsToSelector:@selector(tourRecordMenuViewClickLeft)]) {
            [self.delegate tourRecordMenuViewClickLeft];
        }

    }else{
        if ([self.delegate respondsToSelector:@selector(tourRecordMenuViewClickRight)]) {
            [self.delegate tourRecordMenuViewClickRight];
        }
    }

}

@end
